package com.wxg.tools.md5;

import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;

import com.jfinal.core.Controller;

public class Md5Controller extends Controller{

	private static String ajaxSubmitMd5 = "";
	
	public void index(){
		renderJsp("/tools/md5.jsp");
	}
	
	public void ajaxSubmit(){
		Map<String, String[]> paraMap = getParaMap();
		String mapToString = paraMap.toString();
		String currentMd5 = DigestUtils.md5Hex(mapToString);
		System.out.printf( "[before] ajaxSubmitMd5: %s\n", ajaxSubmitMd5);
		System.out.printf( "mapToString: %s\n", mapToString );
		if(!currentMd5.equals(ajaxSubmitMd5)){
			ajaxSubmitMd5 = currentMd5;
			renderJson("{\"msg\":\"不重复\"}");
			return;
		}
		System.out.printf( "[after ] ajaxSubmitMd5: %s\n", ajaxSubmitMd5);
		renderJson("{\"msg\":\"重复\"}");
	}
	
	
}
